package com.member.web.controller.shop;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.member.common.annotation.Log;
import com.member.common.core.controller.BaseController;
import com.member.common.core.domain.AjaxResult;
import com.member.common.core.page.TableDataInfo;
import com.member.common.enums.BusinessType;
import com.member.common.enums.OrderDeleteEnum;
import com.member.common.utils.poi.ExcelUtil;
import com.member.shop.domain.SysBizCommentPic;
import com.member.shop.domain.SysBizMemberGrade;
import com.member.shop.service.ISysBizCommentPicService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【评价头像管理】控制器
 *
 * @author lixinchen
 * @version 1.0
 * @date 2024-01-02
 **/
@RestController
@RequestMapping("/shop/commentPic")
public class SysBizCommentPicController extends BaseController {
    @Resource
    private ISysBizCommentPicService sysBizCommentPicService;

    /**
     * 查询评价头像管理列表
     */
    @PreAuthorize("@ss.hasPermi('shop:commentPic:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBizCommentPic sysBizCommentPic) {
        startPage();
        LambdaQueryWrapper<SysBizCommentPic> queryWrapper = new LambdaQueryWrapper<SysBizCommentPic>();
        queryWrapper.eq(SysBizCommentPic::getDeleted, OrderDeleteEnum.NOT_DELETE.getKey());
        queryWrapper.orderByDesc(SysBizCommentPic::getCreateTime);
        List<SysBizCommentPic> list = sysBizCommentPicService.selectSysBizCommentPicList(queryWrapper);
        return getDataTable(list);
    }

    /**
     * 导出评价头像管理列表
     */
    @PreAuthorize("@ss.hasPermi('shop:commentPic:export')")
    @Log(title = "评价头像管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBizCommentPic sysBizCommentPic) {
        LambdaQueryWrapper<SysBizCommentPic> queryWrapper = new LambdaQueryWrapper<SysBizCommentPic>();
        List<SysBizCommentPic> list = sysBizCommentPicService.selectSysBizCommentPicList(queryWrapper);
        ExcelUtil<SysBizCommentPic> util = new ExcelUtil<SysBizCommentPic>(SysBizCommentPic.class);
        util.exportExcel(response, list, "评价头像管理数据");
    }

    /**
     * 获取评价头像管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:commentPic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysBizCommentPicService.selectSysBizCommentPicById(id));
    }

    /**
     * 新增评价头像管理
     */
    @PreAuthorize("@ss.hasPermi('shop:commentPic:add')")
    @Log(title = "评价头像管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBizCommentPic sysBizCommentPic) {
        return toAjax(sysBizCommentPicService.insertSysBizCommentPic(sysBizCommentPic));
    }

    /**
     * 修改评价头像管理
     */
    @PreAuthorize("@ss.hasPermi('shop:commentPic:edit')")
    @Log(title = "评价头像管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBizCommentPic sysBizCommentPic) {
        return toAjax(sysBizCommentPicService.updateSysBizCommentPic(sysBizCommentPic));
    }

    /**
     * 删除评价头像管理
     */
    @PreAuthorize("@ss.hasPermi('shop:commentPic:remove')")
    @Log(title = "评价头像管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return toAjax(sysBizCommentPicService.deleteSysBizCommentPicById(id));
    }
}
